#include <accent/algorithms/find.hpp>
#include <accent/functional/is.hpp>
#include "test_base.hpp"

TEST(Find, emptyRange_noPosition) {
  ivec v;
  auto r = all(v);
  ASSERT_FALSE(static_cast<bool>(find(r, is(1))));
}

TEST(Find, oneWrongElement_noPosition) {
  ivec v = { 2 };
  auto r = all(v);
  ASSERT_FALSE(static_cast<bool>(find(r, is(1))));
}

TEST(Find, twoWrongElements_noPosition) {
  ivec v = { 2, 3 };
  auto r = all(v);
  ASSERT_FALSE(static_cast<bool>(find(r, is(1))));
}

TEST(Find, oneRightElement_positionOfElement) {
  ivec v = { 1 };
  auto r = all(v);
  auto pos = find(r, is(1));
  ASSERT_TRUE(static_cast<bool>(pos));
  ASSERT_EQ(1, *pos);
}

TEST(Find, centeredRightElement_positionOfElement) {
  ivec v = { 1, 2, 3 };
  auto r = all(v);
  auto pos = find(r, is(2));
  ASSERT_TRUE(static_cast<bool>(pos));
  ASSERT_EQ(2, *pos);
}
